<template>
	<scroll-view @scrolltolower="handelScrollToLower"scroll-y enable-flex class="video_mian">
		<view class="video_item" v-for="(item,i) in videowp" :key="i" @click="handelGoVieo(item)">
			<image :src="item.img" mode="widthFix"></image>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		props: {
			urlobj: Object
		},
		data() {
			return {
				videowp: [],
				hasMore: true
			}
		},
		watch: {
			urlobj(){
				this.urlobj.params.skip = 0
				this.videowp = []
				this.getDateList()
			}
		},
		mounted(){
			console.log(this.urlobj)
			this.getDateList()
		},
		methods: {
			async getDateList(){
			    const res = await this.request({url: this.urlobj.url,data: this.urlobj.params})
					// console.log(res.data.res)
					if(res.data.res.videowp.length === 0){
						this.hasMore = false
						uni.showToast({
							title: '没有更多数据了',
							icon: "none"
						})
						return
					}
					this.videowp = [...this.videowp,...res.data.res.videowp]
			},
			handelScrollToLower(){
				if(this.hasMore){
					this.urlobj.params.skip += this.urlobj.params.limit
					this.getDateList()
				}else {
					uni.showToast({
						title: '没有更多数据了',
						icon: "none"
					})
				}
			},
			handelGoVieo(item){
				// 1.将数据共享
				getApp().globalData.video = item;
				uni.navigateTo({
					url: "/pages/videoPlay/videoPlay"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.video_mian {
	display: flex;
	flex-wrap: wrap;
	height: calc(100vh - 36px);
	.video_item {
		width: 32.7%;
		border: 2rpx solid #FFFDEF;
	}
}
</style>
